package com.ruoyi.security.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.security.mapper.AfMaintenanceMapper;
import com.ruoyi.security.domain.AfMaintenance;
import com.ruoyi.security.service.IAfMaintenanceService;

/**
 * 运行维护Service业务层处理
 *
 * @author cjie
 * @date 2022-04-15
 */
@Service
public class AfMaintenanceServiceImpl implements IAfMaintenanceService {
    @Autowired
    private AfMaintenanceMapper afMaintenanceMapper;

    /**
     * 查询运行维护
     *
     * @param id 运行维护ID
     * @return 运行维护
     */
    @Override
    public AfMaintenance selectAfMaintenanceById(String id) {
        return afMaintenanceMapper.selectAfMaintenanceById(id);
    }

    /**
     * 查询运行维护列表
     *
     * @param afMaintenance 运行维护
     * @return 运行维护
     */
    @Override
    public List<AfMaintenance> selectAfMaintenanceList(AfMaintenance afMaintenance) {
        return afMaintenanceMapper.selectAfMaintenanceList(afMaintenance);
    }

    /**
     * 新增运行维护
     *
     * @param afMaintenance 运行维护
     * @return 结果
     */
    @Override
    public int insertAfMaintenance(AfMaintenance afMaintenance) {
        afMaintenance.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        afMaintenance.setCreateTime(DateUtils.getNowDate());
        afMaintenance.setCreateBy(SecurityUtils.getUsername());
        return afMaintenanceMapper.insertAfMaintenance(afMaintenance);
    }

    /**
     * 修改运行维护
     *
     * @param afMaintenance 运行维护
     * @return 结果
     */
    @Override
    public int updateAfMaintenance(AfMaintenance afMaintenance) {
        afMaintenance.setUpdateTime(DateUtils.getNowDate());
        afMaintenance.setUpdateBy(SecurityUtils.getUsername());
        return afMaintenanceMapper.updateAfMaintenance(afMaintenance);
    }

    /**
     * 批量删除运行维护
     *
     * @param ids 需要删除的运行维护ID
     * @return 结果
     */
    @Override
    public int deleteAfMaintenanceByIds(String[] ids) {
        return afMaintenanceMapper.deleteAfMaintenanceByIds(ids);
    }

    /**
     * 删除运行维护信息
     *
     * @param id 运行维护ID
     * @return 结果
     */
    @Override
    public int deleteAfMaintenanceById(String id) {
        return afMaintenanceMapper.deleteAfMaintenanceById(id);
    }

    @Override
    public AfMaintenance selectLastAfMaintenance(AfMaintenance o) {
        return afMaintenanceMapper.selectLastAfMaintenance(o);
    }
}
